﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication2.Baga
{
    public partial class resgin : System.Web.UI.Page
    {
        private Sqlserver sqlserver = new Sqlserver();
        protected void Page_Load(object sender, EventArgs e)
        {
           
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            string sql = "insert into StudentInfo(stu_name,password) values(@1,@2)";
            SqlParameter[] parameters ={
            new SqlParameter("@1",TextBox1.Text),
            new SqlParameter("@2",TextBox2.Text)
            };


            if (sqlserver.Extern(sql, parameters))
            {
                Response.Redirect("Longer.aspx");
            }
            else
            {
                Response.Redirect("resgin.aspx");
            }


            //Response.Redirect("resgin.aspx");
        }









        //string str = "server=LAPTOP-8HS8J7NL;uid=sa;pwd=2287431003a;database=Student_db";

        //SqlConnection con = new SqlConnection(str);
        //con.Open();

        //string sql = "insert into StudentInfo (stu_name,password) values(@name,@pwd)";
        //string name = TextBox1.Text;
        //string pwd = TextBox2.Text;

        //SqlParameter[] parameters = {
        //new SqlParameter("@name",name),
        //new SqlParameter("@pwd",pwd)
        //};

        //SqlCommand command = new SqlCommand(sql, con);
        //command.Parameters.AddRange(parameters);

        //int num = command.ExecuteNonQuery();
        //if (num > 0)
        //{
        //    Literal1.Text = "添加成功！！！";
        //    Response.Redirect("Longer.aspx");
        //}
        //else
        //{
        //    Literal1.Text = "添加失败！！！请重新添加!";
        //    Response.Redirect("resgin.aspx");

        //}

    }
    }
